﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace OpcDaNetTest
{
    static class DebugLogHelper
    {
        public static void WriteLog(string log)
        {
            try
            {
                var fileName = Process.GetCurrentProcess().MainModule.FileName;
                var file = new FileInfo(fileName);
                var text = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}>>{log}\r\n";
                var dir = new DirectoryInfo(Path.Combine(file.Directory.FullName, "DebugLog"));
                if (!dir.Exists)
                {
                    dir.Create();
                }
                var path = Path.Combine(dir.FullName, DateTime.Now.ToString("yyyy-MM-dd") + ".log");
                File.AppendAllText(path, text);
            }
            catch
            { }
        }

    }
}
